Column header
Allow users to understand information in each table column and optionally sort column data for easier data discovery
Examples
Basic usage
The basic variant displays the column label in a concise and easily readable manner.
Use cases:
- When the column's content is readily apparent from its label (e.g., "Name," "Date,").
- When sorting or additional information is not required.
Table header
<ColumnHeader content="Table header" />Usage with tooltip
A variant with a tooltip provides supplemental information about the column's data. The tooltip appears on hover or focus.
Use cases:
- When the column label needs clarification or additional context.
- When explaining abbreviations or specialized terminology.
<ColumnHeader content="Table header" tooltip="Some extra info about the column" />Usage with sorting
A sortable variant allows users to sort table data in ascending or descending order by clicking on the header. Visual indicators (arrows) signify the current sorting state.
Use cases:
- When users need to quickly organize and analyze table data.
- When presenting large datasets that require flexible sorting options.
const [direction, setDirection] = useState<"asc" | "desc">("asc");
const currentSort = { property: "property-name" as const, direction: direction };
return (
<ColumnHeader
content="Sortable header"
sort={currentSort}
onSort={() => setDirection(direction === "asc" ? "desc" : "asc")}
property="property-name"
/>
);Properties
Header
| Property | Description | Defined | Value |
|---|---|---|---|
contentRequired | stringContent of the header cell | ||
propertyRequired | stringSortable property | ||
tooltipOptional | | string | objectTooltip to explain the column | ||
sortOptional | | objectProperty and direction the table is currently sorted by | ||
onSortOptional | functionCallback for when a sort button is clicked | ||
defaultSortDirectionOptional | "asc" | "desc"Default direction for sorting the property | ||
data-observe-keyOptional | stringUnique string, used by external script e.g. for event tracking | ||
classNameOptional | stringCustom className that's applied to the outermost element (only intended for special cases) | ||
styleOptional | objectStyle object to apply custom inline styles (only intended for special cases) | ||
tabIndexOptional | numberTab index of the outermost HTML element of the component | ||
onKeyDownOptional | functionCallback for onKeyDown event | ||
onMouseDownOptional | functionCallback for onMouseDown event | ||
onMouseEnterOptional | functionCallback for onMouseEnter event | ||
onMouseLeaveOptional | functionCallback for onMouseLeave event | ||
onFocusOptional | functionCallback for onFocus event | ||
onBlurOptional | functionCallback for onBlur event |
Guidelines
Best practices
Do not use when
Accessibility
Explore detailed guidelines for this component: Accessibility Specifications